﻿/***********************************************************************/
/* Web Jumper Download Page class                                      */
/* Created          : Tan Chun Mun                                     */
/* Date             : 24 March 2008                                    */
/* Copyrighted      :                                                  */
/*****************************Description*******************************/
/*     This class is the internal class that perfrom                   */
/*     downloading web page                                            */
/*****************************Revision**********************************/
/*                                                                     */
/***********************************************************************/

using System;
using System.Configuration;
using System.Collections.Generic;
using System.Text;
using Singleton;


namespace Util
{
    public class WebJumper
    {
        private WebDownloader MyWebDownloader;
        /// <summary>
        /// Create instance of WebJumper
        /// </summary>
        /// <param m_strName="IsSingleton">If singleton call then select true, else false</param>
        public WebJumper(bool IsSingleton)
        {
            
            
            if (IsSingleton)
            {
                MyWebDownloader =
                    Singleton<WebDownloader>.Instance;
            }
            else
            {
                MyWebDownloader = new WebDownloader();
            }
        }
        /// <summary>
        /// Begin to spy the web page
        /// </summary>
        /// <param m_strName="Url">Web page URL</param>
        /// <param m_strName="expiry">Time to stop spying</param>
        /// <returns>Web page contents</returns>
        public String BeginJump(String Url, TimeSpan expiry)
        {
            return MyWebDownloader.GetWebPage(Url, expiry);
            
        }
        /// <summary>
        /// Begin to spy the web page
        /// </summary>
        /// <param m_strName="Url">List of Web Pages Url</param>
        /// <param m_strName="expiry">Time to stop spying</param>
        /// <returns>List of string contents</returns>
        public Dictionary<String,String> BeginJump(List<String> Url, TimeSpan expiry)
        {
            Dictionary<String, String> ReturnData = new Dictionary<String, String>(Url.Capacity);
            foreach(String strLink in Url)
            {
                ReturnData.Add(strLink,
                    MyWebDownloader.GetWebPage(strLink, expiry));
            }
            return ReturnData;
        }
    }
}
